﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WMS_Api.Models;

namespace WMS_Api.Controllers
{
    public class BaseApiController : ApiController
    {
        protected ApiResult Success(string message = "")
        {
            return new ApiResult
            {
                Code = (int)ResultCode.Success,
                Message = message
            };
        }

        protected ApiResult Success(object data)
        {
            return new ApiResult
            {
                Code = (int)ResultCode.Success,
                Message = string.Empty,
                Data = data
            };
        }

        protected ApiResult Success(string message, object data)
        {
            return new ApiResult
            {
                Code = (int)ResultCode.Success,
                Message = message,
                Data = data
            };
        }

        protected ApiResult Error(string message)
        {
            return new ApiResult
            {
                Code = (int)ResultCode.Error,
                Message = message
            };
        }

        protected ApiResult Error(string message, object data)
        {
            return new ApiResult
            {
                Code = (int)ResultCode.Error,
                Message = message,
                Data = data
            };
        }

        protected ApiResult Error(ResultCode code, string message)
        {
            return new ApiResult
            {
                Code = (int)code,
                Message = message
            };
        }

        protected ApiResult Error(ResultCode code, string message, object data)
        {
            return new ApiResult
            {
                Code = (int)code,
                Message = message,
                Data = data
            };
        }
    }
}
